function AddContentANDScroll() {
   newsdiv = document.getElementById('news_scroll');
   commentsdiv = document.getElementById('member_comments_scroll');
   occupationsdiv = document.getElementById('occupations_scroll');
   gallerydiv = document.getElementById('member_gallery');
   tmofferdiv = document.getElementById('tmoffer');

   if(newsdiv != null) {    // **************************** 1. TopMatch News:
     newsdiv.innerHTML = "<div>Member Gallery (optional) Launched!</div>" +
                         "<div>TopMatch UK - Manchester (South) Office Now Open!</div>" +
                         "<div>TopMatch UK - Southampton Office Now Open!</div>" +
                         "<div>TopMatch UK - Lancaster Office Now Open!</div>" +
                         "<div>TopMatch UK - Blackpool Office Now Open!</div>" +
                         "<div>TopMatch UK - Wealden Office Now Open!</div>" +
                         "<div>TopMatch UK - Sheffield Office Now Open!</div>" +
                         "<div>TopMatch UK - West London Office Now Open!</div>" +
                         "<div>TopMatch UK - Doncaster (South) Office Now Open!</div>" +
                         "<div>TopMatch Canada -  Fraser Valley Office Now Open!</div>" +
                         "<div>TopMatch UK - Oxford Office Now Open!</div>" +
                         "<div>TopMatch UK - Bournemouth Office Now Open!</div>" +
                         "<div>TopMatch Canada -  Abbotsford Office Now Open!</div>" +
                         "<div>TopMatch UK - Lancashire Office Now Open!</div>" +
                         "<div>TopMatch Canada - Surrey Office Now Open!</div>" +
                         "<div>TopMatch Free Personality Test launched!</div>" +
                         "<div>TopMatch UK - York Office Now Open!</div>" +
                         "<div>TopMatch Canada - Langley Office Now Open!</div>" +
                         "<div>New Dating Blog launched!</div>" +
                         "<div>FREE Attraction Guide launched!</div>" +
                         "<div>FREE Dating Guide launched!</div>";
     var newsscroll = new scrollObject("news_scroll", 400, 16, "left", 1, 0.4);
     newsscroll.scroll();
   }
   if(commentsdiv != null) {   // **************************** 2. Member Comments:
     commentsdiv.innerHTML = "<div>\"...I am writing to congratulate you for the way in which you have dealt with me. I cannot believe, having never done anything like this before, that you introduce me to my first date who \"ticks almost every box\", and I am extremely grateful!!! -- watch this space!!! Best regards and many thanks again.\"<span>Mr E - February 2010.</span></div>" +
                             "<div>\"...thank you for matching us, everything is going really well and we are planning our first holiday together in the summer...\"<span>Mr N - April 2009.</span></div>" +
                             "<div>\"...It only took one match and we are very happy, without your help I would still be single. I'll be recommending you to all my single friends and I am sure they will be in touch soon! ...\"<span>Miss R - April 2009.</span></div>" +
                             "<div>\"...After 6 months things are still going very well, so well in fact that he's moved in! We're also making plans for the future and he's become such an important part of my life now. Thank you for your help in getting us together! ...\"<span>Miss L - February 2009.</span></div>" +
                             "<div>\"...After 6 months things are still going very well, so well in fact that he's moved in! We're also making plans for the future and he's become such an important part of my life now. Thank you for your help in getting us together! ...\"<span>Miss L - February 2009.</span></div>" +
                             "<div>\"...We moved in together at the end of August and are having a wonderful time, last night he proposed which of course I accepted. You will be top of the wedding invitation list and thank you for introducing us, you have changed our lives!\"<span>Miss R - December 2008.</span></div>" +
                             "<div>\"...the service has been great in it took only 3 matches to find him, we are so happy and want to thank you for helping us!\"<span>Mrs O - November 2008.</span></div>" +
                             "<div>\"...I want to thank TopMatch for making the last seven months of my life so fantastic. I feel like a 21 year old again! Life is so great I want to run to the hill tops and shout out to everyone and tell them how wonderful my life is! ...\"<span>Mrs C. - July 2008.</span></div>" +
                             "<div>\"...My partner and I would like to thank TopMatch so much for bringing us together. We are having a wonderful time and are planning more and more time together, including holidays. What a brilliant service! ...\"<span> Mr R. - January 2008.</span></div>" +
                             "<div>\"...Fantastic Service! What more can we say. It was a daunting experience in the beginning as neither of us had done anything like this before but it really has been worth it. We are having a great time together and have truly found love again. Everyone should try it! ...\"<span>Mr M. & Mrs B. - June 2007.</span></div>" +
                             "<div>\"...Thank you so much for helping me find my partner. We are so perfect for each other - my only regret is that we didn't meet sooner! I was single for 5 years but it took just 3 months from joining TopMatch! ...\"<span> Ann S. - May 2007.</span></div>" +
                             "<div>\"...I was shocked at how genuine the Introductions were that I met. I was sceptical at first but it really opened my eyes. I've met some lovely people and have now been seeing one lady for 5 months-fingers crossed! ...\"<span>Dave F.  - May 2007.</span></div>" +
                             "<div>\"...I had been single for 3 years when my friend trained to become a TopMatch MatchMaking Consultant and convinced me that I had to get off my backside and do something positive to meet someone! I decided to join TopMatch and have now met the love of my life. Thank you TopMatch! ...\"<span>Steve P.  - April 2007.</span></div>" +
                             "<div>\"...Its so simple, just complete a consultation form and wait for the matches to arrive in my email inbox! ...\"<span>Tricia P.  - January 2007.</span></div>" +
                             "<div>\"...I tried Online dating but it's a real minefield - out of date or even bogus photographs, incorrect ages, married people, what a mess! The TopMatch service makes so much more sense! ...\"<span>Alex D.  - January 2007.</span></div>" +
                             "<div>\"...I wanted to write in and say how pleased I was with the service provided by your company. I would recommend all single people join and have done so already to many of my friends! ...\"<span>Claire B. - January 2007.</span></div>" +
                             "<div>\"...as you know I had never used a dating service before except the internet sites, you made joining very easy and put me at ease. We have now been together 3 months and things are going great, I would recommend you to anyone!\"<span>Mr B - September 2008.</span></div>";
     var commentsscroll = new scrollObject("member_comments_scroll", 160, 200, "up", 12000, 1.01);
     commentsscroll.scroll();
   }
   if(occupationsdiv != null) {   // **************************** 3. Member Occupations:
     occupationsdiv.innerHTML = "<div><span>all professionals, company directors,  doctors . . .</span></div>" +
                                "<div><span>teachers, health care workers, business people . . .</span></div>" +
                                "<div><span>sales managers, administrators, self employed . . .</span></div>" +
                                "<div><span>accountants, executives, hr managers, solicitors . . .</span></div>" +
                                "<div><span>bankers, financial advisors, it consultants . . .</span></div>";
     var occupationsscroll = new scrollObject("occupations_scroll", 373, 20, "left", 6000, 1.11);
     occupationsscroll.scroll();
   }
   if(gallerydiv != null) {   // **************************** 4. Member Gallery:

     if(gallerydiv.innerHTML.length > 100) { // data is already added from included php file
         galleryscroll = new scrollObject("member_gallery", 380, 450, "up", 6000, 1.11);
         galleryscroll.scroll();
     } else {
        LoadMemberGallery();   // call function to load data
     }
   }
   if(tmofferdiv != null) { // **************************** 5. Open Offer:
      OpenTMOffer();
   }


}



function SelectGalleryPerson(refno) {
   var refnumber=refno.slice(2);
   var allreferences=document.getElementById('gallery_references').value;
   var choosen_ref_count=Math.round(document.getElementById('choosen_ref_count').value);
   var background='url(http://www.topmatch-uk.com/[img]/transparent.gif)';
   if(allreferences.search(refnumber) >= 0) {
      allreferences=allreferences.replace(refnumber+", ", "");
      choosen_ref_count=choosen_ref_count-1;
   } else {
      if(choosen_ref_count<3) {
         allreferences=allreferences+refnumber+"\, ";
         background='url(http://www.topmatch-uk.com/[img]/gallery_choosen.jpg) no-repeat 265px 0px';
         choosen_ref_count=choosen_ref_count+1;
      } else { 
         alert("You have already chosen 3 members from the gallery!\nNo further selections are allowed.");
      }
   }
document.getElementById('choosen_ref_count').value=choosen_ref_count;
document.getElementById('gallery_references').value=allreferences;
document.getElementById(refno).style.background=background;
}

/* ********************************************************************
* HTML Block Scroller & Marquee JavaScript - v2.0
*  - Copyright 2008 - Licenced for free distribution under the BSDL
*  -     http://www.opensource.org/licenses/bsd-license.php
*
* Have one or more scrolling blocks of HTML anywhere on your webpages.
* The scroller will even pause on mouseover and resume on mouseout.
*
* Version 2.0
*   - Uses DOM-only methods (compatible with application/xhtml+xml)
*   - Blocks are created in the HTML page, rather than as JS variables
*   - Automatic startup on page load

***********************************************************************
*** Instructions ******************************************************
***********************************************************************
* 1. Create the container for the scroller in the body of your HTML:
*
* <div id="scr1"></div>
*
* Where "scr1" is any name you choose.  You don't have to use a <div>
* either.  You may use any block level element that can be pixel
* resized; such as a <span> element to which the display:block; CSS
* property has been applied.
*
***********************************************************************
* 2. Fill the scroller container with child <div> blocks:
*
* <div id="scr1">
*   <div class="default">
*     The first block of the scroller.
*     The contents of this block will be displayed if the browser does
*     not support the scroller.
*   </div>
*   <div>Block 2</div>
*   <div>Block 3</div>
*
*   ...
*
* </div>
*
* Assign the class "default" to the first block, the one which you
* would like displayed if javascript is disabled.
*
***********************************************************************
* 3. Add the following rule(s) to your CSS stylesheet:
*
* #scr1 div {
*  visibility:hidden;
* }
* #scr1, #scr1 div.default {
*   width:160px;
*   height:120px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr1 table tr td div {
*  visibility:visible;
* }
*
* Change both "scr1" to the id you gave to the scroller container.  The
* width and height properties should match those you will use in step 4.
*
* To further style the scroller container, assign CSS properties to the
* scroller target id:
*
* #scr1 {
*   background-color:#f6f6f6;
*   margin:0px auto;
* }
*
* The script will replace each block you add to the container with a
* single-celled <table>. So to style the blocks of your scroller, you
* can style these table cells as if they were actually part of your
* document source:
*
* #scr1 table tr td {
*   padding:10px;
*   color:#ff0000;
*   text-align:center;
*   vertical-align:middle;
* }
*
***********************************************************************
* 4. Create a new scrollObject:
*
* new scrollObject("scr1", 120, 120, "up", 5000, 1.4);
*
* The arguments for this object are as follows:
*  a. - ID of the target tag (from step 1)
*  b. - Width (in pixels) of your scroller
*  c. - Height (in pixels) of your scroller
*  d. - Scroll direction: one of "up", "down", "left" or "right"
*  e. - Amount of time to pause before next scroll begins (ms)
*  f. - Slide-in speed of your scroller (1.001 up to width or height)
*
***********************************************************************
*** To add more scrollers to the same page: ***************************
***********************************************************************
* 1. Create additional containers - with different ID's - and blocks in
*    the body of your HTML
*
* <div id="scr2">
*   <div class="default"><strong>HTML is allowed too!</strong></div>
*   <div><img src="/images/mybanner.jpg" alt=""></div>
*   <div><a href="/home">And links!</a></div>
*   <div>As long as it fits within the dimensions above</div>
* </div>
*
* <div id="scr3">
*   <div class="default">Block 1</div>
*   <div>Block 2</div>
*   <div>Block 3</div>
*   <div>Block 4</div>
* </div>
*
***********************************************************************
* 2. Add the matching rules to your CSS stylesheet
*
* #scr2 div,
* #scr3 div {
*  visibility:hidden;
* }
* #scr2, #scr2 div.default {
*   width:468px;
*   height:60px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr3, #scr3 div.default {
*   width:140px;
*   height:140px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr2 table tr td div,
* #scr3 table tr td div {
*  visibility:visible;
* }
*
***********************************************************************
* 3. Create new scrollObjects for each scroller in the <script> tag:
*
* new scrollObject("scr2", 468, 60, "down", 10000, 1.2);
* new scrollObject("scr3", 140, 140, "right", 4000, 2);
*
***********************************************************************
*** End Instructions **************************************************
*************************************************** BEGIN CODE ***** */


/* ********************************************************************
 * The Mighty ScrollObject
 *   - Don't edit this if you know what's good for ya!
 *
 */
function scrollObject(main, width, height, direct, pause, speed) {
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.slope = (direct == "up" || direct == "left") ? 1 : -1;
  this.prev = this.offset = 0;
  this.curr = 1;
  this.mouse = false;
  this.scroll = function() {
    this.main = document.getElementById(this.main);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    var b = [], c;
    while (this.main.firstChild) if ((c = this.main.removeChild(this.main.firstChild)).nodeName == "DIV") b.push(c);
    for (var x = 0; x < b.length; x++) {
      var table = document.createElement('table');
          table.cellPadding = table.cellSpacing = table.border = "0";
          table.style.position = "absolute";
          table.style.left = table.style.top = "0px";
          table.style.width = table.style.height = "100%";
          table.style.overflow = table.style.visibility = "hidden";
        var tbody = document.createElement('tbody');
          var tr = document.createElement('tr');
            var td = document.createElement('td');
              while (b[x].firstChild)
                  td.appendChild(b[x].removeChild(b[x].firstChild));
              tr.appendChild(td);
            tbody.appendChild(tr);
          table.appendChild(tbody);
      this.main.appendChild(table);
    } b = c = null;
    if (this.main.childNodes.length > 1) {
      this.main.onmouseover = function() { self.mouse = true; };
      this.main.onmouseout = function() { self.mouse = false; };
      setInterval(function() {
        if (!self.offset && self.scrollLoop()) self.main.childNodes[self.curr].style.visibility = "visible";
      }, this.pause);
    } this.main.childNodes[this.prev].style.visibility = "visible";
  };
  this.scrollLoop = function() {
    if (!this.offset) {
      if (this.mouse) return false;
      this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
    if (this.direct == "up" || this.direct == "down") {
      this.main.childNodes[this.curr].style.top = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.top = ((this.offset - this.height) * this.slope) + "px";
    } else {
      this.main.childNodes[this.curr].style.left = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.left = ((this.offset - this.width) * this.slope) + "px";
    }
    if (!this.offset) {
      this.main.childNodes[this.prev].style.visibility = "hidden";
      this.prev = this.curr;
      if (++this.curr >= this.main.childNodes.length) this.curr = 0;
    } else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
  };

}

  if (window.addEventListener) {
    window.addEventListener('load', AddContentANDScroll, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', AddContentANDScroll);


// **************** TM Offer functions
var t2

function OpenTMOffer() {
var bottomvalue = document.getElementById("tmoffer").style.bottom;
if(bottomvalue){var b=bottomvalue;} else {b=(screen.height*2)+"px";}
b = Math.ceil(b.replace(/px/,''));
if(b>100){b=b-10;} else{b=b-1;}
if (b>=60) {
document.getElementById("tmoffer").style.bottom=b+"px";
t2=setTimeout("OpenTMOffer()",2);
}
}

function HideTMOffer(){
document.getElementById("tmoffer").style.display="none";
}
// **************** END TMOffer Functions





var xmlHttp

function LoadMemberGallery() {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!\nMember Gallery cannot be displayed.");
  return;
  } 
var url="./[incl]/member-online-gallery.php";
url=url+"?sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

} 

function stateChanged() { 
   if (xmlHttp.readyState==4){
       gallerydiv = document.getElementById('member_gallery');
       gallerydiv.innerHTML = xmlHttp.responseText; 
       galleryscroll = new scrollObject("member_gallery", 380, 580, "up", 6000, 1.11);
       galleryscroll.scroll();
   } 
}

function GetXmlHttpObject() {
var xmlHttp=null;
try   {   // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest(); }
catch (e) {   // Internet Explorer
  try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
}
return xmlHttp;
}